import { createRouter, createWebHashHistory, RouteRecordRaw, RouterOptions } from "vue-router";
import { routes } from './routes';
import { layoutStore } from '@/store/modules/layout.ts';

const routeList: Array<RouteRecordRaw> = routes as any;

const router = createRouter({
    history: createWebHashHistory(),
    routes: routeList,
} as RouterOptions);

router.beforeEach((to, from, next) => {


    const _routerStore = layoutStore();
    if (from.name && from.path !== '/') {
        _routerStore.fromRoutes = from;
    }
    return next();
})

export default router;
